﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
@* <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head> *@
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">


                <div class="layui-form-item">
                    <label class="layui-form-label">栏位名称</label>
                    <div class="layui-input-block">
                        <input type="text"  id="fieldName" placeholder="请输入" class="layui-input">
                    </div>
                </div>


          


                <div class="layui-form-item" style="float:right">
                    <button type="button" class="layui-btn layui-bg" onclick="Add()">保存</button>
                </div>



            </div>


        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>

</body>

</html>

<script>

    layui.use(function () {


        var form = layui.form;
        var $ = layui.jquery;
    })
    
      

    function Add() {

        var data = {
            fieldName: $("#fieldName").val(),
            cottageId: localStorage.getItem("cottageId")
        }
        console.log(data)
        $.ajax({
            url: "http://localhost:5123/api/Field/Handle",
            type: 'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 0) {
                    layer.msg(res.msg);
                }
                else {
                    layer.msg(res.msg);
                }
            }
        })
    }


</script>